
#include <QCoreApplication>
#include "signaturecoder.h"

namespace Wishmaster
{
	SignatureCoder::SignatureCoder() : Coder()
	{
	}

	SignatureCoder::~SignatureCoder()
	{
	}

	int SignatureCoder::token()
	{
		return 0x01;
	}

	QString SignatureCoder::infoId()
	{
		return "signature";
	}

	bool SignatureCoder::extract(PostPtr& post, const QByteArray& source)
	{
		QString sign = QString::fromUtf8(source);
		ExtraInfo info;
		info.id = infoId();
		info.type = "Signature";
		info.description = qApp->translate("SignatureCoder", "Signature: ") + sign;
		info.data = source;
		info.position = 0;
		info.saveable = false;
		post->setExtra(infoId(), info);
		return true;
	}

	QByteArray SignatureCoder::store(const ExtraInfo& info)
	{
		if(info.id.isEmpty())
			return QByteArray();
		return info.data;
	}
}
